<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增银行种类')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-bank-add">
			<div class="form-group">	
				<label class="col-sm-3 control-label">银行名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">编码：</label>
				<div class="col-sm-8">
					<input id="code" name="code" class="form-control" type="text" required>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "basedata/bank";
		$("#form-bank-add").validate({
            rules:{
                name:{
                    remote: {
                        url:prefix + "/checkBankNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            "name":function () {
                                return $.common.trim($("#name").val());
                            }
                        },
                        dataFilter: function(data, type) {
                            return $.validate.unique(data);
                        }
                    }
                },
            },
            messages: {
                "name": {
                    remote: "银行名称已经存在"
                }
            },
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
                var data = $("#form-bank-edit").serializeArray();
                var name = $("input[id='name']").val();
                var code = $("input[id='code']").val();
                data.push({"name": "name", "value": name});
                data.push({"name": "code", "value": code});
                $.operate.save(prefix + "/add", data);
	        }
	    }
	</script>
</body>
</html>
